package com.godz.controller.index2;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.godz.mapper.index2HpMapper;
import com.godz.pojo.index2Hp;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class hpSecret {
    final
    index2HpMapper hpMapper;//荣誉内容

    public hpSecret(index2HpMapper hpMapper) {
        this.hpMapper = hpMapper;
    }

    @RequestMapping("/index2/priceCon")
    public String PriceCon(Model model, @RequestParam(value = "id") int id) {
        QueryWrapper<index2Hp> wrapper = new QueryWrapper<index2Hp>().eq("id", id);
        index2Hp index2Hp = hpMapper.selectOne(wrapper);
        //由于数据库存的是1,2,3.需要判断1,2,3.分别传给网页不同的显示
        if (index2Hp.getHpCategory() == 1) {
            index2Hp.setCname("科技创新");
        } else if (index2Hp.getHpCategory() == 2) {
            index2Hp.setCname("文化艺术");
        } else {
            index2Hp.setCname("体育竞技");
        }
        model.addAttribute("hpCon", index2Hp);
        return "index2PriceCon";
    }
}
